import SwiftUI

/*
 * 日历示例
 */
class CalendarExample: FCUIView{
    /*
     * 初始化布局
     */
    override func onLoad(){
        let isInit = super.m_isInit
        super.onLoad()
        if !isInit{
            m_paint.defaultUIStyle = "light"
            let width = Double(self.frame.size.width), height = Double(self.frame.size.height)
            renderFaceCat(name:"calendarexample", paint: m_paint, size: FCSize(cx:width, cy:height))
            let tabPage = findViewByName(name:"TabPage2", views:m_paint.views)
            let calendar = FCCalendar()
            calendar.location = FCPoint(x:100, y:100)
            calendar.size = FCSize(cx:200, cy:300)
            addViewToParent(view: calendar, parent: tabPage)
            initCalendar(calendar:calendar)
            let cYear = getYear(years: &calendar.years, year:2022)
            if let cMonth = cYear.months[10]{
                if let cDay = cMonth.days[1]{
                    calendar.setSelectedDay(d: cDay)
                    updateCalendar(calendar:calendar)
                }
            }
        }
    }
}
